In [1]:
from nustar_pysolar import planning, io
import astropy.units as u
import warnings
warnings.filterwarnings('ignore')


WARNING: AstropyDeprecationWarning: 
The 'recommended_units' attribute is deprecated since 3.0 and may be removed
in a future version. Its main use, of representing angles in degrees in frames,
is now done automatically in frames. Further overrides are discouraged but can
be done using a frame's ``frame_specific_representation_info``.
 [astropy.coordinates.representation]
WARNING: AstropyDeprecationWarning: The truth value of a Quantity is ambiguous. In the future this will raise a ValueError. [astropy.units.quantity]

Download the list of occultation periods from the MOC at Berkeley.

Note that the occultation periods typically only are stored at Berkeley for the future and not for the past. So this is only really useful for observation planning.


In [2]:
fname = io.download_occultation_times(outdir='../data/')
print(fname)


../data/NUSTAR.2018_268.SHADOW_ANALYSIS.txt

Download the NuSTAR TLE archive.

This contains every two-line element (TLE) that we've received for the whole mission. We'll expand on how to use this later.

The times, line1, and line2 elements are now the TLE elements for each epoch.


In [3]:
tlefile = io.download_tle(outdir='../data')
print(tlefile)
times, line1, line2 = io.read_tle_file(tlefile)


../data/NuSTAR.tle

Here is where we define the observing window that we want to use.

Note that tstart and tend must be in the future otherwise you won't find any occultation times and sunlight_periods will return an error.


In [4]:
tstart = '2018-09-27T12:00:00'
tend = '2018-09-29T12:10:00'
orbits = planning.sunlight_periods(fname, tstart, tend)

We want to know how to orient NuSTAR for the Sun.

We can more or less pick any angle that we want. But this angle has to be specified a little in advance so that the NuSTAR SOC can plan the "slew in" maneuvers. Below puts DET0 in the top left corner (north-east with respect to RA/Dec coordinates).

This is what you tell the SOC you want the "Sky PA angle" to be.


In [ ]:
pa = planning.get_nustar_roll(tstart, 0)
print("NuSTAR Roll angle for Det0 in NE quadrant: {}".format(pa))

Set up the offset you want to use here:

The first element is the direction +WEST of the center of the Sun, the second is the offset +NORTH of the center of the Sun.

If you want multiple pointing locations you can either specify an array of offsets or do this "by hand" below.


In [5]:
offset = [0., 0.]*u.arcsec

Loop over each orbit and correct the pointing for the same heliocentric pointing position.

Note that you may want to update the pointing for solar rotation. That's up to the user to decide and is not done here.


In [6]:
for ind, orbit in enumerate(orbits):
    midTime = (0.5*(orbit[1] - orbit[0]) + orbit[0])
    sky_pos = planning.get_skyfield_position(midTime, offset, parallax_correction=True)
    print("Orbit: {}".format(ind))
    print("Orbit start: {} Orbit end: {}".format(orbit[0].isoformat(), orbit[1].isoformat()))
    print('Aim time: {} RA (deg): {} Dec (deg): {}'.format(midTime.isoformat(), sky_pos[0], sky_pos[1]))
    print("")


[#################################] 100% deltat.data
[#################################] 100% Leap_Second.dat
Orbit: 0
Orbit start: 2018-09-27T11:47:30 Orbit end: 2018-09-27T12:48:50
Aim time: 2018-09-27T12:18:10 RA (deg): 183.75361356568973 deg Dec (deg): -1.625719371459118 deg

Orbit: 1
Orbit start: 2018-09-27T13:24:10 Orbit end: 2018-09-27T14:25:30
Aim time: 2018-09-27T13:54:50 RA (deg): 183.8140598312915 deg Dec (deg): -1.651848616119325 deg

Orbit: 2
Orbit start: 2018-09-27T15:00:50 Orbit end: 2018-09-27T16:02:10
Aim time: 2018-09-27T15:31:30 RA (deg): 183.87451015897653 deg Dec (deg): -1.6779770391065716 deg

Orbit: 3
Orbit start: 2018-09-27T16:37:30 Orbit end: 2018-09-27T17:38:50
Aim time: 2018-09-27T17:08:10 RA (deg): 183.93496457952233 deg Dec (deg): -1.7041046132672741 deg

Orbit: 4
Orbit start: 2018-09-27T18:14:10 Orbit end: 2018-09-27T19:15:20
Aim time: 2018-09-27T18:44:45 RA (deg): 183.9953853799726 deg Dec (deg): -1.730207465641824 deg

Orbit: 5
Orbit start: 2018-09-27T19:50:50 Orbit end: 2018-09-27T20:52:00
Aim time: 2018-09-27T20:21:25 RA (deg): 184.05584807362263 deg Dec (deg): -1.7563332675768444 deg

Orbit: 6
Orbit start: 2018-09-27T21:27:30 Orbit end: 2018-09-27T22:28:40
Aim time: 2018-09-27T21:58:05 RA (deg): 184.1163149494681 deg Dec (deg): -1.7824581376201163 deg

Orbit: 7
Orbit start: 2018-09-27T23:04:10 Orbit end: 2018-09-28T00:05:20
Aim time: 2018-09-27T23:34:45 RA (deg): 184.17678603903374 deg Dec (deg): -1.8085820489443332 deg

Orbit: 8
Orbit start: 2018-09-28T00:40:50 Orbit end: 2018-09-28T01:42:00
Aim time: 2018-09-28T01:11:25 RA (deg): 184.23726137164883 deg Dec (deg): -1.8347049735933072 deg

Orbit: 9
Orbit start: 2018-09-28T02:17:20 Orbit end: 2018-09-28T03:18:40
Aim time: 2018-09-28T02:48:00 RA (deg): 184.29770322148536 deg Dec (deg): -1.8608030756632203 deg

Orbit: 10
Orbit start: 2018-09-28T03:54:00 Orbit end: 2018-09-28T04:55:20
Aim time: 2018-09-28T04:24:40 RA (deg): 184.358187127757 deg Dec (deg): -1.8869239533280437 deg

Orbit: 11
Orbit start: 2018-09-28T05:30:40 Orbit end: 2018-09-28T06:32:00
Aim time: 2018-09-28T06:01:20 RA (deg): 184.41867536674616 deg Dec (deg): -1.9130437614726525 deg

Orbit: 12
Orbit start: 2018-09-28T07:07:20 Orbit end: 2018-09-28T08:08:40
Aim time: 2018-09-28T07:38:00 RA (deg): 184.47916796899807 deg Dec (deg): -1.9391624728524897 deg

Orbit: 13
Orbit start: 2018-09-28T08:44:00 Orbit end: 2018-09-28T09:45:20
Aim time: 2018-09-28T09:14:40 RA (deg): 184.5396649641145 deg Dec (deg): -1.9652800596363136 deg

Orbit: 14
Orbit start: 2018-09-28T10:20:40 Orbit end: 2018-09-28T11:22:00
Aim time: 2018-09-28T10:51:20 RA (deg): 184.60016638196825 deg Dec (deg): -1.9913964941719113 deg

Orbit: 15
Orbit start: 2018-09-28T11:57:20 Orbit end: 2018-09-28T12:58:40
Aim time: 2018-09-28T12:28:00 RA (deg): 184.6606722523983 deg Dec (deg): -2.0175117487942527 deg

Orbit: 16
Orbit start: 2018-09-28T13:34:00 Orbit end: 2018-09-28T14:35:20
Aim time: 2018-09-28T14:04:40 RA (deg): 184.72118260520833 deg Dec (deg): -2.0436257958247768 deg

Orbit: 17
Orbit start: 2018-09-28T15:10:40 Orbit end: 2018-09-28T16:12:00
Aim time: 2018-09-28T15:41:20 RA (deg): 184.78169747016562 deg Dec (deg): -2.069738607571108 deg

Orbit: 18
Orbit start: 2018-09-28T16:47:20 Orbit end: 2018-09-28T17:48:40
Aim time: 2018-09-28T17:18:00 RA (deg): 184.84221687700008 deg Dec (deg): -2.095850156326551 deg

Orbit: 19
Orbit start: 2018-09-28T18:24:00 Orbit end: 2018-09-28T19:25:20
Aim time: 2018-09-28T18:54:40 RA (deg): 184.90274085540284 deg Dec (deg): -2.121960414369625 deg

Orbit: 20
Orbit start: 2018-09-28T20:00:40 Orbit end: 2018-09-28T21:02:00
Aim time: 2018-09-28T20:31:20 RA (deg): 184.9632694350251 deg Dec (deg): -2.1480693539635745 deg

Orbit: 21
Orbit start: 2018-09-28T21:37:20 Orbit end: 2018-09-28T22:38:40
Aim time: 2018-09-28T22:08:00 RA (deg): 185.0238026454773 deg Dec (deg): -2.1741769473560497 deg

Orbit: 22
Orbit start: 2018-09-28T23:14:00 Orbit end: 2018-09-29T00:15:20
Aim time: 2018-09-28T23:44:40 RA (deg): 185.0843405163274 deg Dec (deg): -2.2002831667784046 deg

Orbit: 23
Orbit start: 2018-09-29T00:50:40 Orbit end: 2018-09-29T01:52:00
Aim time: 2018-09-29T01:21:20 RA (deg): 185.1448830771 deg Dec (deg): -2.226387984445387 deg

Orbit: 24
Orbit start: 2018-09-29T02:27:20 Orbit end: 2018-09-29T03:28:40
Aim time: 2018-09-29T02:58:00 RA (deg): 185.20543035697114 deg Dec (deg): -2.2524913723642555 deg

Orbit: 25
Orbit start: 2018-09-29T04:04:00 Orbit end: 2018-09-29T05:05:20
Aim time: 2018-09-29T04:34:40 RA (deg): 185.26598238598342 deg Dec (deg): -2.278593303095897 deg

Orbit: 26
Orbit start: 2018-09-29T05:40:40 Orbit end: 2018-09-29T06:42:00
Aim time: 2018-09-29T06:11:20 RA (deg): 185.3265391932202 deg Dec (deg): -2.3046937486118244 deg

Orbit: 27
Orbit start: 2018-09-29T07:17:20 Orbit end: 2018-09-29T08:18:40
Aim time: 2018-09-29T07:48:00 RA (deg): 185.3871008080209 deg Dec (deg): -2.330792681055481 deg

Orbit: 28
Orbit start: 2018-09-29T08:54:00 Orbit end: 2018-09-29T09:55:20
Aim time: 2018-09-29T09:24:40 RA (deg): 185.44766725967577 deg Dec (deg): -2.3568900725513027 deg

Orbit: 29
Orbit start: 2018-09-29T10:30:40 Orbit end: 2018-09-29T11:32:00
Aim time: 2018-09-29T11:01:20 RA (deg): 185.50823857742458 deg Dec (deg): -2.3829858952042215 deg

This is where you actually make the Mosaic


In [9]:
# Just use the first orbit...or choose one. This may download a ton of deltat.preds, which is a known 
# bug to be fixed.

orbit = orbits[20]
planning.make_mosaic(orbit, write_output=True, make_regions=True)


('Step PA', <Quantity 115.78189166 deg>)
Orbit start: 2018-09-28T20:00:40 Orbit end: 2018-09-28T21:02:00
('Dwell per position:', datetime.timedelta(0, 147, 200000))

NuSTAR Roll Angle to get DET0 in top right 25.78 deg


In [ ]:


In [ ]: